var ReviewMessage = {}

ReviewMessage.init = function(articleId){
	ReviewMessage.initGrid(articleId);
}

ReviewMessage.initGrid = function(articleId){
	$('#reviewMessageList').datagrid({
		width:768,
		height:'auto',
		striped: true,
		url:context+'/manager/review-message!reviewMessageListData.action?articleId='+articleId,
		remoteSort: false,
		idField:'id',
		columns:[[
					{field:'reviewName',title:'回复人',width:100,align:'center'},
					{field:'reviewContent',title:'回复内容',width:396,height:100,align:'center'},
					{field:'reviewTime',title:'回复时间',width:140,align:'center'},
					{field:'id',title:'操作',width:100,align:'center',formatter:function(value,rec){
						return "<a onClick='ReviewMessage.deleteReviewMessage("+rec.id+","+articleId+")' style='color:blue'>删除</a>";
					}}
				]],
		pagination:true,
		loadMsg:'正在加载数据,请等待...',
		rownumbers:true
	});
	var p = $('#reviewMessageList').datagrid('getPager');
	if (p){
		$(p).pagination({
			showPageList:false,
			beforePageText:'第',
			afterPageText:"页，共<font color='blue'> {pages} </font>页",
			displayMsg:"当前显示 <font color='red'>{from}</font> 到 <font color='red'>{to}</font> 条记录，共<font color='red'> {total} </font>条记录",
		});
	}
}

ReviewMessage.deleteReviewMessage=function(id,articleId){
	$.ajax({
		type:'POST',
		url:'review-message!delete.action',
		data:{'id':id},
		success:function(data){
			alert(data);
			ReviewMessage.initGrid(articleId);
		}
	})
}

ReviewMessage.openDialog=function(content){
	$('#reivewMessageDialog').window({   
		modal:true,
		width:320,
		iconCls:'icon-ok',
		minimizable:false,
		onClose: function(){
		}      		
	}); 
	$('#reivewMessageDialog').window('open');
	$('#reviewMessageText').text(content); //有待验证
}
ReviewMessage.closeDialog= function(){
	$('#reivewMessageDialog').window('close');
}
